import { name } from "@/common/config.js"

const storage = {
  save (key, value) {
	try {
		uni.setStorageSync(name + "_" + key, value);
	} catch (e) {
		// error
	}  	
  },
  get (key, defaultValue = {}) {
	try {
	    const value  = uni.getStorageSync(name + "_" + key);
	    return value;
	} catch (e) {
	    return defaultValue;
	}
  },  
  remove (key) {
	try {  
		uni.removeStorageSync(name + "_" + key);
	} catch (e) {
		// error
	}  
  },
  clear () {
	try {
		uni.clearStorageSync();
	} catch (e) {
		// error
	}  
  }
}

export default storage
